﻿//日期格式化
Date.prototype.format = function (format) //author: meizz 
{
    var o = {
        "M+": this.getMonth() + 1, //month 
        "d+": this.getDate(),    //day 
        "h+": this.getHours(),   //hour 
        "m+": this.getMinutes(), //minute 
        "s+": this.getSeconds(), //second 
        "q+": Math.floor((this.getMonth() + 3) / 3),  //quarter 
        "S": this.getMilliseconds() //millisecond 
    }
    if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
    (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o) if (new RegExp("(" + k + ")").test(format))
        format = format.replace(RegExp.$1,
      RegExp.$1.length == 1 ? o[k] :
        ("00" + o[k]).substr(("" + o[k]).length));
    return format;
}

function StrToDate(JSONDateString) {
    var date = new Date(parseInt(JSONDateString.replace("/Date(", "").replace(")/", ""), 10));
    return date.format("yyyy-MM-dd hh:mm:ss");
}


//辅料删除事件
function flDelClick(obj) {
    if (confirm("确认要删除？")) {
        $.ajax({
            type: "post",
            url: "/ashx/InStorage.ashx",
            data: { delhlid: $(obj).attr("alt") },
            success: function (msg) {
                //alert('删除成功');
            }
        });
        $(obj).parent().parent().remove();
    }
}

//损耗删除事件
function shDelClick(obj) {
    if (confirm("确认要删除？")) {
        $.ajax({
            type: "post",
            url: "/ashx/InStorage.ashx",
            data: { delshid: $(obj).attr("alt") },
            success: function (msg) {
                //alert('删除成功');
            }
        });
        $(obj).parent().parent().remove();
    }
}


//处理前的删除事件
function unDelClick(obj) {
    if (confirm("确认要删除？")) {
        $.ajax({
            type: "post",
            url: "/ashx/InStorage.ashx",
            data: { delunid: $(obj).attr("alt") },
            success: function (msg) {
                //alert('删除成功');
            }
        });
        $(obj).parent().parent().remove();
    }
}



//入库删除事件
function delClick(obj) {
    if (confirm("确认要删除？")) {
        $.ajax({
            type: "post",
            url: "/ashx/InStorage.ashx",
            data: { delbarid: $(obj).attr("alt") },
            success: function (msg) {
                //alert('删除成功');
            }
        });
        $(obj).parent().parent().remove();
        getNwtCur();
    }
}

//修改事件 处理前
function updateUnClick(obj) {
    var unid = $(obj).attr("alt");
    $.ajax({
        type: "post",
        url: "/ashx/InStorage.ashx",
        data: { "unid": unid },
        success: function (msg) {
            var unobj = eval('(' + msg + ')');

            $("#txtungc").val(unobj.GoodsCode);
            $("#txtunga").val(unobj.GoodsName);
            $("#txtungwt").val(unobj.gwt);
            $("#txtunnwt").val(unobj.nwt);
            $("#txtunqty").val(unobj.qty);
            $("#txtunhw").html(unobj.rubbishcode);
            $("#lblunHwType").val(unobj.rubbishtype);
            $("#tdunldno").val(unobj.continNo);
            $("#tdunmemo").val(unobj.remark);
            $(".hid_unid").val(unobj.id);
            $("#hidungdid").val(unobj.goodsid);
        }
    });
}

//修改事件 条形码重复
function updateClick(obj) {

    var barid = $(obj).attr("alt");
    $.ajax({
        type: "post",
        url: "/ashx/InStorage.ashx",
        data: { "barid": barid },
        success: function (msg) {
            var barobj = eval('(' + msg + ')');

            $("#txtgc").val(barobj.goodscode);
            $("#txtgn").val(barobj.goodsname);
            $("#txtgwt").val(barobj.gwt);
            $("#txttare1").val(barobj.tare1);
            $("#txttare2").val(barobj.tare2);
            $("#txtnwt").html(barobj.nwt);
            $("#txtBoxCount").val(barobj.boxcount);
            $("#txtqty").val(barobj.qty);
            $("#txtsid").val(barobj.stroageNo);
            $("#txthw").val(barobj.rubbishcode);
            $("#lblHwType").html(barobj.rubbishtype);
            $("#txtcomeunder").val(barobj.comeunder);
            $("#txtdno").val(barobj.rdh);
            $("#txtpn").val(barobj.packageno);
            $("#lblInDate").html(StrToDate(barobj.createdate));
            $("#txtremark").val(barobj.remark);
            $("#lblBarcode").html(barobj.barcodevalue);
            $(".HidPostion").val(barobj.storageid);
            $("#hidgdid").val(barobj.goodsid);
        }
    });

}


$(document).ready(function () {
    $("#div_SelectReport").hide();

    var unGoodsType = "DH";
    switch ($(".hidintype").val()) {
        case "F":
            unGoodsType = "DH";
            break;
        case "Z":
            unGoodsType = "BDH";
            break;
        default:
            unGoodsType = "B";
            break;
    }

    //处理前物品编码选取
    $("#txtungc").autocomplete({
        source: function (request, response) {
            $.ajax({
                url: "/ashx/Autocomplete.ashx",
                data: { "goods": $("#txtungc").val(), "type": unGoodsType },
                dataType: "json",
                success: function (data) {
                    response($.map(data, function (item) {
                        return {
                            label: item.label + " " + item.value,
                            value: item.value,
                            lab: item.label,
                            goodsid: item.goodsid
                        }
                    }));
                },
                error: function (result, status) {
                    alert('请输入正确的物品编码');
                }
            })

        },
        select: function (event, ui) {
            $("#txtungc").val(ui.item.lab);
            $("#txtunga").val(ui.item.value);
            $("#hidungdid").val(ui.item.goodsid);
            return false;
        },

        minLength: "1"
    });

    //入库物品编码选取
    $("#txtgc").autocomplete({
        source: function (request, response) {
            $.ajax({
                url: "/ashx/Autocomplete.ashx",
                data: { "goods": $("#txtgc").val(), "type": "B" },
                dataType: "json",
                success: function (data) {
                    response($.map(data, function (item) {
                        return {
                            label: item.label + " " + item.value,
                            value: item.value,
                            lab: item.label,
                            goodsid: item.goodsid
                        }
                    }));
                },
                error: function (result, status) {
                    alert('请输入正确的物品编码');
                }
            })

        },
        select: function (event, ui) {
            $("#txtgc").val(ui.item.lab);
            $("#txtgn").val(ui.item.value);
            $("#hidgdid").val(ui.item.goodsid);
            return false;
        },

        minLength: "1"
    });


    //库位下拉选择根据处理地做筛选
    $("#txtsid").autocomplete({
        source: function (request, response) {
            $.ajax({
                url: "/ashx/BasicStorage.ashx",
                data: { "word": $("#txtsid").val()
                , "graphic": escape($(".hidOutDepart").val())
                , "belong": escape($(".hidInDepart").val())
                },
                dataType: "json",
                success: function (data) {
                    response(data);
                },
                error: function (result, status) {
                    alert('请输入正确的库位');
                }
            })

        },
        select: function (event, ui) {
            $("#txtsid").val(ui.item.label);
            $(".HidPostion").val(ui.item.value);
            return false;
        },

        minLength: "1"
    });



    //处理前危废下拉选择
    $("#txtunhw").autocomplete({
        source: function (request, response) {
            $.ajax({
                url: "/ashx/Autocomplete.ashx",
                data: { "goods": $("#txtunhw").val(), "type": "hw" },
                dataType: "json",
                success: function (data) {
                    response($.map(data, function (item) {
                        return {
                            label: item.label + " " + item.value,
                            value: item.value,
                            lab: item.label,
                            goodsid: item.goodsid
                        }
                    }));
                },
                error: function (result, status) {
                    alert('请输入正确的危废编码');
                }
            })

        },
        select: function (event, ui) {
            $("#txtunhw").val(ui.item.lab);
            $("#lblunHwType").html(ui.item.value);
            $("#hidunHwid").val(ui.item.goodsid);
            return false;
        },

        minLength: "1"
    });



    //入库危废下拉选择
    $("#txthw").autocomplete({
        source: function (request, response) {
            $.ajax({
                url: "/ashx/Autocomplete.ashx",
                data: { "goods": $("#txthw").val(), "type": "hw" },
                dataType: "json",
                success: function (data) {
                    response($.map(data, function (item) {
                        return {
                            label: item.label + " " + item.value,
                            value: item.value,
                            lab: item.label,
                            goodsid: item.goodsid
                        }
                    }));
                },
                error: function (result, status) {
                    alert('请输入正确的危废编码');
                }
            })

        },
        select: function (event, ui) {
            $("#txthw").val(ui.item.lab);
            $("#lblHwType").html(ui.item.value);
            $("#hiduHwid").val(ui.item.goodsid);
            return false;
        },

        minLength: "1"
    });



    //净重计算
    $("#txttare2,#txttare1,#txtgwt").blur(function () {
        if ($("#txttare1").val() != "" && $("#txtgwt").val() != "" && $("#txttare2").val() != "") {
            $("#txtnwt").html(parseFloat($("#txtgwt").val()) - parseFloat($("#txttare1").val()) - parseFloat($("#txttare2").val()));
        }
    });


    //分类插入函数
    function unInsert() {
        $("#txtungc").focus();
        var jston = {
            "goodscode_un": $("#txtungc").val(),
            "goodsname_un": $("#txtunga").val(),
            "goodsid_un": $("#hidungdid").val(),
            "gwt_un": $("#txtungwt").val(),
            "nwt_un": $("#txtunnwt").val(),
            "qty_un": $("#txtunqty").val(),
            "remark": $("#tdunmemo").val(),
            "rcode": $("#txtunhw").val(),
            "rname": $("#lblunHwType").html(),
            "continno": $("#tdunldno").val(),
            "parid": $(".hiddenParSid").val(),
            "cjoid": $(".hiddencjoid").val(),
            "isprocess": "un",
            "unmemo": $("#tdunmemo").val(),
            "hidInStoID": $(".hiddenInSid").val(),
            "wrlno": $(".txtIn").val(),
            "alllock": $("#chkInStr").attr("checked"),
            "islocak": $("#chkIsLock").attr("checked"),
            "oper": $(".hiddenOper").val(),
            "unid": $(".hid_unid").val(),
            "load": $(".inputLoadNum").val(),
            "loadnumid": $(".hiddenloadid").val(),
            "inDepart": $(".hidInDepart").val(),
            "outDepart": $(".hidOutDepart").val(),
            "month": $(".dropMonth").val(),
            "intype": $(".hidInstype").val()
        };

        $.ajax({
            type: "post",
            url: "/ashx/InStorage.ashx",
            data: jston,
            success: function (msg) {
                if ($(".hid_unid").val() == '0') {
                    var obj = eval('(' + msg + ')');
                    var tr = "<tr>";
                    tr += "<td>" + ($('#tabF tr').length - 1) + "</td>";
                    tr += "<td class='barcodevalue'>" + obj[0].GoodsCode + "</td>";
                    tr += "<td>" + obj[0].GoodsName + "</td>";
                    tr += "<td>" + obj[0].gwt + "</td>";
                    tr += "<td>" + obj[0].nwt + "</td>";
                    tr += "<td>" + obj[0].qty + "</td>";
                    tr += "<td>" + obj[0].rubbishcode + "</td>";
                    tr += "<td>" + obj[0].rubbishtype + "</td>";
                    tr += "<td>" + obj[0].continNo + "</td>";
                    tr += "<td>" + obj[0].remark + "</td>";
                    tr += "<td><img src='/images/jian.png' onclick='javascript:unDelClick(this)' alt=" + obj[0].id + " width='16' height='17' class='jian'/></td>";
                    tr += "<td><img src='/images/icons/button_update.gif' alt='" + obj[0].id + "' onclick='javascript:updateUnClick(this)' height='17' class='update'/>";
                    tr += "<input id='hid_" + obj[0].id + "' type='hidden' value='" + obj[0].id + "' /></td>";

                    tr += "</tr>";
                    if (obj[0] != null) {
                        $("#tabF").append(tr);
                        $(".txtIn").val(obj[1].wrlno);

                    }
                }
                else { //修改插入返回值
                    $(".hid_unid").val("0");
                }
                $("#txtungc").val("");
                $("#txtunga").val("");
                $("#txtungwt").val("");
                $("#txtunnwt").val("");
                $("#txtunqty").val("");
                $("#tdunmemo").val("");
                $("#txtunhw").val("");
                $("#lblunHwType").html("");
                $("#tdunldno").val("");
                $("#tdunmemo").val("");
                $(".hiddenInSid").val(obj[1].id);
                $(".hidInDepart").val(obj[1].InDepart);
                $(".hidOutDepart").val(obj[1].OutDepart);
            }
        });

    }

    //入库插入函数
    function instorage() {
        $("#txtgc").focus();
        var jston = { "loadnumid": $(".hiddenloadid").val(),
            "goodscode": $("#txtgc").val(),
            "goodsname": $("#txtgn").val(),
            "goodsid": $("#hidgdid").val(),
            "comeunder": $("#txtcomeunder").val(),
            "gwt": $("#txtgwt").val(),
            "nwt": $("#txtnwt").html(),
            "tare1": $("#txttare1").val(),
            "tare2": $("#txttare2").val(),
            "qty": $("#txtqty").val(),
            "packageno": $("#txtpn").val(),
            "storageid": $("#HidPostion").val(),
            "storageno": $("#txtsid").val(),
            "parid": $(".hiddenParSid").val(),
            "hidInStoID": $(".hiddenInSid").val(),
            "wrlno": $(".txtIn").val(),
            "oper": $(".hiddenOper").val(),
            "boxamount": $("#txtBoxCount").val(),
            "vload": $(".HidVLoad").val(),
            "rcode": $("#txthw").val(),
            "rname": $("#lblHwType").html(),
            "barcode": $("#lblBarcode").html(),
            "alllock": $("#chkInStr").attr("checked"),
            "islocak": $("#chkIsLock").attr("checked"),
            "inDepart": $(".hidInDepart").val(),
            "outDepart": $(".hidOutDepart").val(),
            "month": $(".dropMonth").val(),
            "cjoid": $(".hiddencjoid").val(),
            "intype": $(".hidInstype").val()
        };



        $.ajax({
            type: "post",
            url: "/ashx/InStorage.ashx",
            data: jston,
            success: function (msg) {
                if (msg == 'CZ') {
                    alert('超过出库单重量，请重新输入');
                }
                else if (msg == 'SD') {
                    alert("请选择合法库位");
                }
                else {
                    var obj = eval('(' + msg + ')');
                    var tr = "<tr>";
                    tr += "<td>" + ($('#tab tr').length - 1) + "</td>";
                    tr += "<td class='barcodevalue'>" + obj[0].goodscode + "</td>";
                    tr += "<td>" + obj[0].goodsname + "</td>";
                    tr += "<td>" + obj[0].gwt + "</td>";
                    tr += "<td>" + obj[0].tare1 + "</td>";
                    tr += "<td>" + obj[0].tare2 + "</td>";
                    tr += "<td class='clsnwt'>" + obj[0].nwt + "</td>";
                    tr += "<td>" + obj[0].boxcount + "</td>";
                    tr += "<td>" + obj[0].qty + "</td>";
                    tr += "<td>" + obj[0].rubbishcode + "</td>";
                    tr += "<td>" + obj[0].rubbishtype + "</td>";
                    tr += "<td>" + obj[0].comeunder + "</td>";
                    tr += "<td>" + obj[0].packageno + "</td>";
                    tr += "<td>" + obj[0].stroageNo + "</td>";
                    tr += "<td>" + StrToDate(obj[0].createdate) + "</td>";
                    tr += "<td>" + obj[0].barcodevalue + "</td>";
                    tr += "<td><input type='checkbox' class='flase' title='" + obj[0].id + "' " + GetIsLock(obj[0].isLocak) + "  />锁定</td>";
                    tr += "<td><img src='/images/jian.png'  onclick='javascript:delClick(this)' alt='" + obj[0].id + "' width='16' height='17' class='jian'/></td>";
                    tr += "<td><img src='/images/icons/button_update.gif' onclick='javascript:updateClick(this)' alt='" + obj[0].id + "' height='17' class='update'/></td>";
                    tr += "<td><a href='/Storage/BarcodeImg.aspx?barCodeID=" + obj[0].id + "' target='_blank'>条码重打</a></td>";
                    tr += "</tr>";
                    if (obj[0] != null) {
                        $("#tab").append(tr);
                        $(".txtIn").val(obj[1].wrlno);
                    }
                    getNwtCur();
                    $("#txtgc").val("");
                    $("#txtgn").val("");
                    $("#dropt").html("");
                    $("#txtgwt").val("0");
                    $("#txtnwt").html("0");
                    $("#txttare1").val("0");
                    $("#txttare2").val("0");
                    $("#txtqty").val("");
                    $("#txtpn").val("");
                    $("#lblBarcode").html("");
                    $("#lblInDate").html("");
                    $("#txtsid").val("");
                    $("#txtBoxCount").val("");
                    $("#txthw").val("");
                    $("#lblHwType").html("");
                    $("#txtcomeunder").val("");
                    $(".hiddenInSid").val(obj[1].id);
                    //                    $(".hidInDepart").val(obj[1].InDepart);
                    //                    $(".hidOutDepart").val(obj[1].OutDepart);
                    $("#chkIsLock").attr("checked", false); //xiehm
                    //打印小标签
                    window.open("BarCodeImg.aspx?barcodeid=" + obj[0].id, "_blank");
                }
            }
        });
    }

    //分类汇总客户端输入验证
    function checkInputClassify() {
        strErr = "";
        if ($("#txtungc").val() == "") strErr += "物品编码不能为空！\n";
        if ($("#txtunga").val() == "") strErr += "物品名称不能为空！\n";
        if ($("#txtunnwt").val() == "" || isNaN($("#txtunnwt").val())) strErr += "净重必须输入数字！\n";
        if ($("#txtungwt").val() == "" || isNaN($("#txtungwt").val())) strErr += "毛重必须输入数字！\n";
        if ($("#txtunqty").val() == "" || isNaN($("#txtunqty").val())) strErr += "数量必须输入数字！\n";
        return strErr;

    }

    //入库验证函数
    function InventoryVerification() {
        strErr2 = "";
        if ($("#txtgc").val() == "") strErr2 += "物品编码不能为空！\n";
        if ($("#txtgn").val() == "") strErr2 += "物品名称不能为空\n";
        if ($("#txtgwt").val() == "" || isNaN($("#txtgwt").val())) strErr2 += "毛重必须输入数字！\n";
        if ($("#txttare1").val() == "" || isNaN($("#txttare1").val())) strErr2 += "皮重1必须输入数字！\n";
        if ($("#txttare2").val() == "" || isNaN($("#txttare2").val())) strErr2 += "皮重2必须输入数字！\n";
        if ($("#txtBoxCount").val() == "" || isNaN($("#txtBoxCount").val())) strErr2 += "箱数必须输入数字！\n";
        if ($("#txtqty").val() == "" || isNaN($("#txtqty").val())) strErr2 += "数量必须输入数字！\n";
        if ($("#txtsid").val() == "") strErr2 += "必须选择库位！\n";
        return strErr2;
    }

    //分类插入
    $("#btnunprocessadd").click(function () {
        var strErr = checkInputClassify();
        if (strErr == "") {
            //分类插入函数
            unInsert();
        }
        else {
            alert(strErr);
        }

    });

    //入库插入
    $("#btnSaveBarcode").click(function () {
        var strErr = InventoryVerification();
        if (strErr == "") {
            //调用插入函数
            instorage();
        }
        else {
            alert(strErr);
        }
    });

    //2013-03-05 梁玲
    //判断是否选中
    function GetIsLock(islock) {
        if (islock == true)
            return "checked";
        else
            return "";
    }
    //checkbox绑定点击事件

    $(".flase").each(function () {
        $(this).click(function () {
            var id = $(this).attr("title");
            var isLock = "0";
            if ($(this).attr("checked") == "checked")
                isLock = "1";
            else
                isLock = "0";
            updataLock(id, isLock);
        });

    });

    function updataLock(id, Islock) {
        $.ajax({
            type: "post",
            url: "/ashx/Inwrl.ashx",
            data: { barcodeid: id, islock: Islock },
            success: function (msg) {
                alert(msg);
            }
        });
    }

});

function getNwtCur() {
    var curnwt = 0.00;
    $(".clsnwt").each(function () {
        curnwt += parseFloat($(this).html());
    });
    $(".tdCurNwt").html(curnwt);

}

//辅料客户端输入验证
function checkInputFL() {
    strErr = "";
    if ($("#txtgcode_fl").val() == "") strErr += "物品编码不能为空！\n";
    if ($("#txtgname_fl").val() == "") strErr += "物品名称不能为空！\n";
    if ($("#txtnwt_fl").val() == "" || isNaN($("#txtnwt_fl").val())) strErr += "净重必须输入数字！\n";
    if ($("#txtgwt_fl").val() == "" || isNaN($("#txtgwt_fl").val())) strErr += "毛重必须输入数字！\n";
    if ($("#txtqty_fl").val() == "" || isNaN($("#txtqty_fl").val())) strErr += "数量必须输入数字！\n";
    return strErr;

}

//损耗客户端输入验证
function checkInputSH() {
    strErr = "";
    if ($("#txtgcode_sh").val() == "") strErr += "物品编码不能为空！\n";
    if ($("#txtgname_sh").val() == "") strErr += "物品名称不能为空！\n";
    if ($("#txtnwt_sh").val() == "" || isNaN($("#txtnwt_sh").val())) strErr += "净重必须输入数字！\n";
    if ($("#txtgwt_sh").val() == "" || isNaN($("#txtgwt_sh").val())) strErr += "毛重必须输入数字！\n";
    if ($("#txtqty_sh").val() == "" || isNaN($("#txtqty_sh").val())) strErr += "数量必须输入数字！\n";
    return strErr;

}


//辅料插入函数
function flInsert() {
    $("#txtgcode_fl").focus();
    var jston = {
        "gcode_fl": $("#txtgcode_fl").val(),
        "gname_fl": $("#txtgname_fl").val(),
        "gwt_fl": $("#txtgwt_fl").val(),
        "nwt_fl": $("#txtnwt_fl").val(),
        "qty_fl": $("#txtqty_fl").val(),
        "remark_fl": $("#txtremark_fl").val(),
        "parid": $(".hiddenParSid").val(),
        "cjoid": $(".hiddencjoid").val(),
        "hidInStoID": $(".hiddenInSid").val(),
        "wrlno": $(".txtIn").val(),
        "alllock": $("#chkInStr").attr("checked"),
        "oper": $(".hiddenOper").val(),
        "flid": $("#hidflid").val(),
        "load": $(".inputLoadNum").val(),
        "loadnumid": $(".hiddenloadid").val(),
        "inDepart": $(".hidInDepart").val(),
        "outDepart": $(".hidOutDepart").val(),
        "month": $(".dropMonth").val(),
        "intype": $(".hidInstype").val()
    };

    $.ajax({
        type: "post",
        url: "/ashx/InStorage.ashx",
        data: jston,
        success: function (msg) {
       
                var obj = eval('(' + msg + ')');
                var tr = "<tr>";
                tr += "<td>" + ($('#tabfl tr').length - 1) + "</td>";
                tr += "<td>" + obj[0].goodscode + "</td>";
                tr += "<td>" + obj[0].goodsname + "</td>";
                tr += "<td>" + obj[0].gwt + "</td>";
                tr += "<td>" + obj[0].nwt + "</td>";
                tr += "<td>" + obj[0].qty + "</td>";
                tr += "<td>" + obj[0].remark + "</td>";
                tr += "<td><img src='/images/jian.png' onclick='javascript:flDelClick(this)' alt=" + obj[0].id + " width='16' height='17' class='jian'/></td>";
                tr += "<td><img src='/images/icons/button_update.gif' alt='" + obj[0].id + "' onclick='javascript:updateUnClick(this)' height='17' class='update'/>";
                tr += "<input id='hid_" + obj[0].id + "' type='hidden' value='" + obj[0].id + "' /></td>";

                tr += "</tr>";
                if (obj[0] != null) {
                    $("#tabfl").append(tr);
                    $(".txtIn").val(obj[1].wrlno);

                }
          
                $(".hidflid").val("0");
      
            $("#txtgcode_fl").val("");
            $("#txtgname_fl").val("");
            $("#txtgwt_fl").val("");
            $("#txtnwt_fl").val("");
            $("#txtqty_fl").val("");
            $("#txtremark_fl").val("");
            $(".hiddenInSid").val(obj[1].id);
            $(".hidInDepart").val(obj[1].InDepart);
            $(".hidOutDepart").val(obj[1].OutDepart);
        }
    });

}


//损耗插入函数
function shInsert() {
    $("#txtgcode_sh").focus();
    var jston = {
        "gcode_sh": $("#txtgcode_sh").val(),
        "gname_sh": $("#txtgname_sh").val(),
        "gwt_sh": $("#txtgwt_sh").val(),
        "nwt_sh": $("#txtnwt_sh").val(),
        "qty_sh": $("#txtqty_sh").val(),
        "remark_sh": $("#txtremark_sh").val(),
        "parid": $(".hiddenParSid").val(),
        "cjoid": $(".hiddencjoid").val(),
        "hidInStoID": $(".hiddenInSid").val(),
        "wrlno": $(".txtIn").val(),
        "alllock": $("#chkInStr").attr("checked"),
        "oper": $(".hiddenOper").val(),
        "shid": $("#hidshid").val(),
        "load": $(".inputLoadNum").val(),
        "loadnumid": $(".hiddenloadid").val(),
        "inDepart": $(".hidInDepart").val(),
        "outDepart": $(".hidOutDepart").val(),
        "month": $(".dropMonth").val(),
        "intype": $(".hidInstype").val()
    };

    $.ajax({
        type: "post",
        url: "/ashx/InStorage.ashx",
        data: jston,
        success: function (msg) {
            if (msg != 'CZ') {
                var obj = eval('(' + msg + ')');
                var tr = "<tr>";
                tr += "<td>" + ($('#tabsh tr').length - 1) + "</td>";
                tr += "<td>" + obj[0].goodscode + "</td>";
                tr += "<td>" + obj[0].goodsname + "</td>";
                tr += "<td>" + obj[0].gwt + "</td>";
                tr += "<td>" + obj[0].nwt + "</td>";
                tr += "<td>" + obj[0].qty + "</td>";
                tr += "<td>" + obj[0].remark + "</td>";
                tr += "<td><img src='/images/jian.png' onclick='javascript:shDelClick(this)' alt=" + obj[0].id + " width='16' height='17' class='jian'/></td>";
                tr += "<td><img src='/images/icons/button_update.gif' alt='" + obj[0].id + "' onclick='javascript:updateUnClick(this)' height='17' class='update'/>";
                tr += "<input id='hid_" + obj[0].id + "' type='hidden' value='" + obj[0].id + "' /></td>";

                tr += "</tr>";
                if (obj[0] != null) {
                    $("#tabsh").append(tr);
                    $(".txtIn").val(obj[1].wrlno);
                }

                $(".hidshid").val("0");
                $("#txtgcode_sh").val("");
                $("#txtgname_sh").val("");
                $("#txtgwt_sh").val("");
                $("#txtnwt_sh").val("");
                $("#txtqty_sh").val("");
                $("#txtremark_sh").val("");
                $(".hiddenInSid").val(obj[1].id);
                $(".hidInDepart").val(obj[1].InDepart);
                $(".hidOutDepart").val(obj[1].OutDepart);
            }
            else {
                alert('超重');
            }
        }
    });
}